package com.zhihaoliang.bezier.cubic

import android.graphics.PointF
import android.util.Log
import android.view.View
import com.zhihaoliang.bezier.base.BaseActivity
import com.zhihaoliang.bezier.databinding.ActivityCubicBezierBinding
import com.zhihaoliang.bezier.widgets.BezierView

/**
 * @author 支豪亮
 * @date 2023/1/10 10:10
 * @des  CubicBezierEasing 的贝塞尔曲线的展示
 */
class CubicBezierActivity : BaseActivity<ActivityCubicBezierBinding>(),CubicBezierCallback {

    override fun initDataBinding() = ActivityCubicBezierBinding.inflate(layoutInflater)

    override fun initView() {
        super.initView()

        val fastOutSlowIn = CubicBezier("FastOutSlowInEasing", PointF(0.4f, 0.0f), PointF(0.2f, 1.0f),
                                        "p(0.4f, 0.0f) p(0.2f, 1.0f)")
        val linearOutSlowIn = CubicBezier("LinearOutSlowInEasing", PointF(0.0f, 0.0f),
                                          PointF(0.2f, 1.0f), "p(0.0f, 0.0f) p(0.2f, 1.0f)")

        val fastOutLinearIn = CubicBezier("FastOutLinearInEasing", PointF(0.4f, 0.0f),
                                          PointF(1.0f, 1.0f), "p(0.4f, 0.0f) p(1.0f, 1.0f)")

        val linearEasing = CubicBezier("linearEasing", PointF(0.2f, 0.2f), PointF(0.8f, 0.8f),
                                       "p(0.2f, 0.2f) p(0.8f, 0.8f)")


        dataBinding.list = listOf(fastOutSlowIn, linearOutSlowIn, fastOutLinearIn, linearEasing)
        dataBinding.callback = this
    }

    override fun onStartBezier(bezierView: View) {
        Log.e("onStartBezier","onStartBezier : $bezierView")
        if(bezierView is BezierView) bezierView.start()
    }


}